[ ]
ErrorsCollection

[ ]

Synthesised documentation from language/operators language/operators

From language/operators

See Original text in context

The Array_constructor" class="index-entry">Array constructor returns an itemized Array that does not flatten in list context. Check this:

say .raku for [3,2,[1,0]]; # OUTPUT: «3␤2␤$[1, 0]␤»

This array is itemized, in the sense that every element constitutes an item, as shown by the $ preceding the last element of the array, the (list) item contextualizer.

From language/operators

See Original text in context

sub postcircumfix:<[ ]>(@container**@index,
                        :$k:$v:$kv:$p:$exists:$delete)

Universal interface for positional access to zero or more elements of a @container, a.k.a. "array indexing operator".

my @alphabet = 'a' .. 'z';
say @alphabet[0];                   # OUTPUT: «a␤» 
say @alphabet[1];                   # OUTPUT: «b␤» 
say @alphabet[*-1];                 # OUTPUT: «z␤» 
say @alphabet[100]:exists;          # OUTPUT: «False␤» 
say @alphabet[1701020].join;  # OUTPUT: «raku␤» 
say @alphabet[23 .. *].raku;        # OUTPUT: «("x", "y", "z")␤» 
 
@alphabet[12= "B""C";
say @alphabet[0..3].raku;           # OUTPUT: «("a", "B", "C", "d")␤»

See Subscripts, for a more detailed explanation of this operator's behavior and for how to implement support for it in custom types.